package com.luna.serviceImpl;

import com.luna.beans.Message;
import com.luna.beans.ShowMessage;
import com.luna.dao.MessageDao;
import com.luna.service.MessageService;

import java.util.List;

public class MessageServiceImpl implements MessageService {

    @Override
    public List<ShowMessage> msgList(int user_id) {
        List<ShowMessage> list = null;
        MessageDao messageDao = new MessageDao();
        try {
            List<Message> tmp_list = messageDao.selectMessagesByUserId(user_id);
            list = messageDao.getShowMessage(tmp_list);
            System.out.println("list: " + list);
        } catch (Exception ignored) {}
        return list;
    }

    @Override
    public boolean readMessages(int user_id) {
        MessageDao messageDao = new MessageDao();
        try {
            messageDao.readMessage(user_id);
        } catch (Exception _e) {
            return false;
        }
        return true;
    }
}
